<template>
  <div class="uploaded__container">
    <div class="uploaded__title">{{ prizeDate }} 本轮开奖</div>

    <div class="uploaded__image">
      <img :src="img8" alt="" width="100%" />
    </div>

    <p class="uploaded__info">历史开奖结果可在【我的奖品】中查看</p>
    <div class="unlogin_btn pluse_ani" @click="toShare">
      分享
    </div>
  </div>
</template>

<script>
import {
  timeFormat,
  activityShare,
  envFunc,
  loadImg,
  convertImgToBase64
} from "@/utils/util";
import { img8, shareWx, shareIndex } from "@/constant";
export default {
  computed: {
    memberDetail() {
      return this.$store.state.mainPage.memberDetail;
    },
    prizeDate() {
      return timeFormat(
        this.$store.state.mainPage.memberDetail.prizeDate,
        "M月D日 HH:mm"
      );
    },
    app() {
      return this.$store.state.app;
    }
  },
  data: function() {
    return {
      img8
    };
  },
  methods: {
    async toShare() {
      let url = `${location.origin}${
        location.pathname
      }/#/?isskey=1&acte=btnshare&v=${new Date().getTime()}`;

      // 首页接口
      // TODO: 修改shareIndex
      let img = await loadImg(shareIndex);
      let imgUrl = convertImgToBase64(img);

      let params = {
        title: "不限购票平台! 不限时间地点! 不限出行项目!",
        shareImg: shareWx,
        path: `pages/web/web?url=${encodeURIComponent(url)}&isSocket=true`,
        shareUrl: url,
        imgUrl
      };

      envFunc(
        () => {
          activityShare(params);
        },
        () => {
          this.app.correspond.share({
            shareInfo: {
              currentPath: url,
              title: "不限购票平台! 不限时间地点! 不限出行项目!", //默认
              imageUrl: shareWx,
              path: `/pages/web/web?url=${encodeURIComponent(
                url
              )}&isSocket=true`
            },
            shareVisible: true
          });
        }
      );
    }
  }
  // beforeDestroy() {
  //   this.app.correspond.close();
  // }
};
</script>

<style lang="scss" scoped>
@import "@/app.scss";

.uploaded__container {
  padding: 38px 15px 67px 22px;
  background: #ffffff;
  border-radius: 30px;
  text-align: center;

  .uploaded__title {
    font-size: 36px;

    font-weight: 800;
    color: #2e2d2b;
  }

  .uploaded__info {
    font-size: 24px;

    font-weight: 500;
    color: #666666;
  }

  .uploaded__image {
    margin: 37px 0 44px 0;
  }
}
</style>
